<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>



    // let obj=zoomObj();
    // let obj=zoomObj();


    // function zoomObj() {
    //   let arr = [{ level: 0, zoom: 10, cls: "circle" }, { level: 1, zoom: 12, cls: "circle" }, { level: 2, zoom: 15, cls: "rect" },]
    //   let index = -1;
    //   return function () {
    //     index++;
    //     return arr[index];
    //   }
    // }

    // let func1=zoomObj();

    // let obj1=func1();
    // let obj2=func1();
    // let obj3=func1();
    // console.log(obj1);
    // console.log(obj2);
    // console.log(obj3);



    // ====================================

    // 匿名函数和自调用函数 





    // zoomObj 第一个函数的返回值 
    const zoomObj = (function () {
      let arr = [{ level: 0, zoom: 10, cls: "circle" }, { level: 1, zoom: 12, cls: "circle" }, { level: 2, zoom: 15, cls: "rect" },]
      let index = -1;
      return function () {
        index++;
        return arr[index];
      }
    })();



    let obj1=zoomObj();
    let obj2=zoomObj();
    let obj3=zoomObj();
    console.log(obj1);
    console.log(obj2);
    console.log(obj3);



  </script>
</body>

</html>